﻿using System.Collections.Generic;
using MRGSP.SurveyMaster.Core;
using MRGSP.SurveyMaster.Core.Service.Utils;

namespace MRGSP.SurveyMaster.Service.Utils
{
    public class ValueReaderFactory
    {
        private static readonly IDictionary<ControlType, IValueReader> Implementations = new Dictionary<ControlType, IValueReader> 
                                                                                        { 
                                                                                            { ControlType.Radio, new RadioReader() }, 
                                                                                            { ControlType.Checkbox, new CheckBoxReader() }, 
                                                                                            { ControlType.Textbox, new TextBoxReader() },
                                                                                            { ControlType.TextArea, new TextBoxReader() } 
                                                                                        };

        private static readonly IValueReader TheDefault = new DefaultReader();

        public static IValueReader Get(ControlType type)
        {
            return !Implementations.Keys.Contains(type) ? TheDefault : Implementations[type];
        }
    }
}